package com.app.Cutofftime;

import android.content.Context;
import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

import java.util.List;

public class AssAdapter extends ArrayAdapter<AssItem> {
    private int resourceId;
    public AssAdapter(Context context, int textViewResourceId, List<AssItem> objects){
        super(context,textViewResourceId,objects);
        resourceId=textViewResourceId;
    }
    @Override
    public View getView(int position, View convertView, ViewGroup parent){
        AssItem item=getItem(position);   //获取当前项的实例
        View view= LayoutInflater.from(getContext()).inflate(resourceId,parent,false);
        TextView itemTitle=(TextView) view.findViewById(R.id.title);
        itemTitle.setText(item.getTitle());
        itemTitle.setTextColor(Color.parseColor(item.getColor()));
        TextView itemModule=(TextView) view.findViewById(R.id.module);
        itemModule.setText(item.getModule());
        TextView itemEndtime=(TextView) view.findViewById(R.id.end_time);
        itemEndtime.setText(item.getEndTime());
        TextView itemRetime=(TextView) view.findViewById(R.id.remaining_time);
        itemRetime.setText(item.getReTimeStr());
        TextView itemType=(TextView) view.findViewById(R.id.ass_type);
        itemType.setText(item.getType());
        TextView itemProportion=(TextView) view.findViewById(R.id.proportion);
        itemProportion.setText(item.getProportion());
        TextView itemDec=(TextView) view.findViewById(R.id.dec);
        itemDec.setText(item.getDec());
        return view;
    }
}
